package ar.edu.utn.frba.dds.tp.primeraEntrega.tests;


import java.util.ArrayList;
import java.util.List;

import junit.framework.Assert;

import org.joda.time.LocalDate;
import org.junit.Before;
import org.junit.Test;

import ar.edu.utn.frba.dds.tp.primeraEntrega.code.CantParseException;
import ar.edu.utn.frba.dds.tp.primeraEntrega.code.Fecha;
import ar.edu.utn.frba.dds.tp.primeraEntrega.code.Formato;
import ar.edu.utn.frba.dds.tp.primeraEntrega.code.FormatoFlexible;
import ar.edu.utn.frba.dds.tp.primeraEntrega.code.FormatoSimple;

public class FlexibleTest {
	
	private LocalDate date;
	private FormatoFlexible flexible;
	
	/*
	 * Tester Mariano Sanchez de Vera
	 */

	@Before
	public void setUp() throws Exception {
		List<Formato> formatos = new ArrayList<Formato>();
		formatos.add(new FormatoSimple("MM-dd-yyyy"));
		formatos.add(new FormatoSimple("dd-MM-yyyy"));
		formatos.add(new FormatoSimple("dd-MM-yyyy"));
		date = new LocalDate(2009, 10, 15);
		flexible = new FormatoFlexible(formatos);
		
	}
	
	@Test
	public void testParsea() {
		Assert.assertEquals(date, Fecha.Parsear("15-10-2009", flexible));
	}
	
	@Test (expected = CantParseException.class)
	public void testNoParsea() {
		Assert.assertEquals(date, Fecha.Parsear("2009-10-15", flexible));
	}

}
